<template>
  <div id="main_container">
    <div class="main_container_top">
      <div class="main_top_msg">
        <div class="el-icon-document" style="color: #1296db"></div>
        <div>
          <p>总订单</p>
          <span>{{ totalAmount }}</span>
        </div>
      </div>

      <div class="main_top_msg" style="color: #d4247a">
        <div class="el-icon-coin"></div>
        <div>
          <p>总销售额</p>
          <span>{{ totalOrder }}</span>
        </div>
      </div>

      <div class="main_top_msg" style="color: #1296db">
        <div class="el-icon-document-copy"></div>
        <div>
          <p>今日订单数</p>
          <span>{{ todayOrder }}</span>
        </div>
      </div>

      <div class="main_top_msg" style="color: #61fc6b">
        <div class="el-icon-medal-1"></div>
        <div>
          <p>今日销售额</p>
          <span>{{ totayAmount }}</span>
        </div>
      </div>
    </div>

    <div id="myChart" class="main_container_main"></div>
  </div>
</template>

<script>
import { totaldata } from "@/apis/echarts";
import * as echarts from "echarts";

export default {
  data() {
    return {
      totalAmount: "",
      totalOrder: "",
      todayOrder: "",
      totayAmount: "",
    };
  },
  mounted() {
    totaldata().then((res) => {
      // console.log(res.data);
      this.totalAmount = res.data.totalAmount;
      this.totalOrder = res.data.totalOrder;
      this.todayOrder = res.data.todayOrder;
      this.totayAmount = res.data.totayAmount;
      //初始化
      let my = echarts.init(document.getElementById("myChart"));

      //调用
      my.setOption({
        title: {
          text: "折线图堆叠",
        },
        tooltip: {
          trigger: "axis",
        },
        legend: {
          data: ["邮件营销", "联盟广告"],
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: res.data.xData,
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            name: "邮件营销",
            type: "line",
            stack: "总量",
            data: res.data.orderData,
          },
          {
            name: "联盟广告",
            type: "line",
            stack: "总量",
            data: res.data.amountData,
          },
        ],
      });
    });
  },
};
</script>

<style lang="less" scoped>
#main_container {
  height: 100%;
  display: flex;
  flex-direction: column;
  .main_container_top {
    height: 100px;
    display: flex;
    justify-content: space-around;
    background-color: #f0f2f5;
    margin-bottom: 20px;
    .main_top_msg {
      display: flex;
      align-items: center;
      background-color: #fff;
      padding: 10px;
      width: 20%;

      .el-icon-document,
      .el-icon-coin,
      .el-icon-document-copy,
      .el-icon-medal-1 {
        font-size: 80px;
        margin-right: 30px;
      }
      p {
        color: #d2d2d2;
        font-size: 20px;
      }
      span {
        font-weight: bold;
        font-size: 20px;
      }
    }
  }

  .main_container_main {
    background-color: #fff !important;
    flex: 1;
  }
}
</style>